/********************************************************************
	Coder: vincent
	E-Mail:	vincent213@live.cn
*********************************************************************/

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class HitDataProcess
{
	public class HitCountRecord
	{
		public int nCurCount;
		public float fLastPlayTime = 0;
		
		public bool UpdateCount(float fTimeStep,int nMaxCount,float curTime)
		{
            if (curTime - fLastPlayTime > fTimeStep && nCurCount < nMaxCount)
			{
				nCurCount++;
                fLastPlayTime = curTime;
				return true;
			}
			
			return false;
		}
	}
	
	public Dictionary<int,HitCountRecord> m_mapHitTargetCount = new Dictionary<int, HitCountRecord>();

	public bool UpdateCount(int nTargetID,float fTimeStep,int nMaxCount,float curTime)
	{
		if(!IsExistTarget(nTargetID))
			m_mapHitTargetCount.Add(nTargetID,new HitCountRecord());
		
		HitCountRecord hitRecord;
		if(m_mapHitTargetCount.TryGetValue(nTargetID,out hitRecord))
		{
            return hitRecord.UpdateCount(fTimeStep, nMaxCount, curTime);
		}
		else
			return false;
		
	}
	public void Reset()
	{
		m_mapHitTargetCount.Clear();
	}
	
	public bool IsExistTarget(int nID)
	{
		HitCountRecord hitrecord;
		if(m_mapHitTargetCount.TryGetValue(nID, out hitrecord))
			return true;
		else 
			return false;
	}
}

